package com.hzit.deadqueue.customer;

import com.hzit.deadqueue.config.MqConfig;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class DQCustomer {


    /**
     * 死信队列A的消费者
     */
    @RabbitListener(queues = MqConfig.DEAD_LETTER_QUEUEA_NAME)
    public void reciveDqA(Channel channel, Message message){
        System.out.println("----------死信队列A的消费者开始消费----------");

        String msg = new String(message.getBody());

        System.out.println("死信队列A 获取消息："+ msg);

    }

    /**
     * 死信队列B的消费者
     */

    @RabbitListener(queues = MqConfig.DEAD_LETTER_QUEUEB_NAME)
    public void reciveDqB(Channel channel, Message message){
        System.out.println("----------死信队列B的消费者开始消费----------");


        String msg = new String(message.getBody());

        System.out.println("死信队列B 获取消息："+ msg);

    }

}
